package service

import (
	"context"
	"video-srv/basic/config"
	__ "video-srv/basic/proto"
	"video-srv/handler/model"
)

// server is used to implement helloworld.GreeterServer.
type Server struct {
	__.UnimplementedVideoServer
}

// SayHello implements helloworld.GreeterServer
func (s *Server) VideoAdd(_ context.Context, in *__.VideoAddReq) (*__.VideoAddResp, error) {

	video := model.Video{

		Title:      in.Title,
		Content:    in.Content,
		Label:      in.Label,
		Permission: in.Permission,
		Image:      in.Image,
	}
	config.DB.Debug().Create(&video)
	return &__.VideoAddResp{
		VideoId: int64(video.ID),
	}, nil
}
